<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>构造函数的继承</title>
</head>
<body>
  
  <script>
      // 定义Person构造函数(类)
      function Person(name, age, height, address) {
      this.name = name
      this.age = age
      this.height = height
      this.address = address
    }

    Person.prototype.running = function() {
      console.log(this.name + " running ~")
    }
    Person.prototype.eating = function() {
      console.log("eating~")
    }

    function Student(name, age, height, address, sno, score) {
      Person.call(this, name, age, height, address)
      this.score = score
      this.sno = sno
    }

    var p = new Person("why", 20)
    Student.prototype = p

    Student.prototype.studying = function() {
      console.log("studying~")
    }

    var stu1 = new Student("koby", 18, 111, 220)
    var stu2 = new Student("james", 23,333, 110)
    
    stu1.running()

    console.log(stu1.name, stu1.age)
    console.log(stu2.name, stu2.age)
  </script>
</body>
</html>